#include <iostream>
using namespace std;
#define ElemType int
#define MAXSIZE 6
typedef struct {
	ElemType data[MAXSIZE];
	int len;
}Sqlist;
typedef struct node
{
	int date;
	struct node *next;
}LNode, *LinkList;
void initList(Sqlist &list) {
	for (int i = 0; i < MAXSIZE; i++) {
		list.data[i] = 0;
	}
	list.len = 0;
}
void addDate(Sqlist &list, ElemType e[], int n) {
	initList(list);
	for (int i = 0; i < n && i < MAXSIZE; i++) {
		list.data[list.len] = e[i];
		list.len++;
	}
}
/*头插法*/
void Link_Insert(LinkList &L, Sqlist &list) {
	LNode *s;
	L = (LinkList)malloc(sizeof(LNode));
	L->next = NULL;
	for (int x = 0; x < list.len; x++)
	{
		s = (LinkList)malloc(sizeof(LNode));
		s->date = list.data[x];
		s->next = L->next;
		L->next = s;
	}
}
/*打印顺序表*/
void displayList(Sqlist &list) {
	for (int i = 0; i < list.len; i++) {
		cout << list.data[i] << " ";
	}
	cout << endl;
}
/*打印链表*/
void displayLink(LinkList &L) {
	LNode *p;
	p = L->next;
	while (p != NULL)
	{
		printf("%d ", p->date);
		p = p->next;
	}
	cout << endl;
}
int main()
{
	int a[] = { 1,2,3,4,5,6 };
	Sqlist list;
	LNode *head;
	addDate(list, a, 6);
	displayList(list);
	Link_Insert(head, list);
	displayLink(head);
}